/* Firefox userChrome.css tweaks ********************************************************/
/* Github: https://github.com/aris-t2/customcssforfx ************************************/
/****************************************************************************************/


/************************************************/
/* cheat main menu button into title bar ********/
/************************************************/

:root {
  --appbutton_in_titlebar: 95px !important;
}

/* menubar adjustments */
#main-window:is([tabsintitlebar],[customtitlebar]) #toolbar-menubar {
  padding-inline-start: var(--appbutton_in_titlebar) !important;
}
#main-window:is([tabsintitlebar],[customtitlebar])[sizemode="maximized"] #toolbar-menubar {
  padding-inline-start: var(--appbutton_in_titlebar) !important;
}
#main-window[uidensity=compact]:is([tabsintitlebar],[customtitlebar]) #toolbar-menubar {
  padding-inline-start: var(--appbutton_in_titlebar) !important;
}
#main-window[uidensity=compact]:is([tabsintitlebar],[customtitlebar])[sizemode="maximized"] #toolbar-menubar {
  padding-inline-start: var(--appbutton_in_titlebar) !important;
}

/* tabs toolbar adjustments */
#main-window:is([tabsintitlebar],[customtitlebar]) #toolbar-menubar[autohide="true"][inactive="true"] ~ #TabsToolbar {
  padding-inline-start: var(--appbutton_in_titlebar) !important;
}

#main-window:is([tabsintitlebar],[customtitlebar])[sizemode="maximized"] #toolbar-menubar[autohide="true"][inactive="true"] ~ #TabsToolbar {
  padding-inline-start: var(--appbutton_in_titlebar) !important;
}

#main-window[uidensity=compact]:is([tabsintitlebar],[customtitlebar]) #toolbar-menubar[autohide="true"][inactive="true"] ~ #TabsToolbar {
  padding-inline-start: var(--appbutton_in_titlebar) !important;
}

#main-window[uidensity=compact]:is([tabsintitlebar],[customtitlebar])[sizemode="maximized"] #toolbar-menubar[autohide="true"][inactive="true"] ~ #TabsToolbar {
  padding-inline-start: var(--appbutton_in_titlebar) !important;
}

#main-window:is([tabsintitlebar],[customtitlebar])[sizemode="fullscreen"] #TabsToolbar {
 padding-inline-start: var(--appbutton_in_titlebar) !important;
}

#main-window:is([tabsintitlebar],[customtitlebar]):not([sizemode="fullscreen"]) #toolbar-menubar[autohide="true"]:not([inactive="true"]) ~ #TabsToolbar,
#main-window:is([tabsintitlebar],[customtitlebar]):not([sizemode="fullscreen"]) #toolbar-menubar[autohide="false"] ~ #TabsToolbar {
  margin-top: 4px !important;
}

/* appbutton */
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-button {
  appearance: none !important;
  position: fixed !important;
  display: flex !important;
  height: 22px !important;
  margin: 0 !important;
  margin-inline-start: 0px !important;
  border: unset !important;
  box-shadow: unset !important;
  padding-left: 0px !important;
  padding-right: 0px !important;
  top: 0px !important;
}

/* code for macOS/Linux */

@media not (-moz-platform: windows) {
	#main-window:is([tabsintitlebar],[customtitlebar])[sizemode="maximized"] #PanelUI-button {
	  top: 0 !important;
	}  
}

#main-window:is([tabsintitlebar],[customtitlebar])[sizemode="fullscreen"] #PanelUI-button {
  top: 0 !important;
}

#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-button #PanelUI-menu-button {
  background-clip: padding-box !important;
  padding: 0 1.4em 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  padding-inline-start: 1.4em !important;
  padding-inline-end: 2.1em !important;
  height: 22px !important;
  border-radius: 0 0 4px 4px;
  border-top: none !important;
  border-right: 1px solid !important;
  border-left: 1px solid !important;
  border-bottom: 1px solid !important;
}

/* code for macOS/Linux */
@media not (-moz-platform: windows) {
  #main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-button #PanelUI-menu-button {
	max-width: var(--appbutton_in_titlebar) !important;
  }
}

/* hide button in fullscreen mode, if toolbars get automatically hidden */
#main-window:is([tabsintitlebar],[customtitlebar])[sizemode="fullscreen"] #navigator-toolbox[style*="margin-top: -"] #PanelUI-button {
  visibility: collapse !important;
}

/* dropmarker icon / arrow */
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-button .toolbarbutton-icon {
  margin-top: 2px !important;
  margin-bottom: 0px !important;
  list-style-image: url("../../image/dropdown-arrow-inverted.svg") !important;
  width: 9px !important;
  height: 7px !important;
  background: unset !important;
  box-shadow: unset !important;
  margin-inline-end: -2px !important;
}

#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button::after {
  display: block !important;
  color: white !important;
  font-weight: bold !important;
  text-shadow: 0 0 1px rgba(0,0,0,.7),
			   0 1px 1.5px rgba(0,0,0,.5) !important;
  border: unset !important;
  box-shadow: unset !important;
  margin-inline-start: 8px !important;
}

#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button .toolbarbutton-badge-stack {
  position: absolute;
  right: 0px;
}

/* 'Firefox' title */
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button[label="Firefox"]::after,
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button:not([label="Nightly"],[label="Firefox Nightly"],[label="Firefox Developer Edition"],[label="Firefox"],[label="Tor Browser"],[label="Tor-Browser"])::after {
  content: "Firefox" !important;
}

/* 'DevFox' title */
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button[label="Firefox Developer Edition"]::after {
  content: "DevFox" !important;
}

/* 'Nightly' title */
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button:is([label="Nightly"],[label="Firefox Nightly"])::after {
  content: "Nightly" !important;
}

/* 'Tor-Browser' title */
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button:-moz-any([label="Tor Browser"],[label="Tor-Browser"])::after {
  content: "TorFox" !important;
}

/* adjust button badge stack */
#main-window:is([tabsintitlebar],[customtitlebar]) :is(#PanelUI-button,#PanelUI-menu-button):not([checked],[open],:active) > .toolbarbutton-badge-stack,
#main-window:is([tabsintitlebar],[customtitlebar]) :is(#PanelUI-button,#PanelUI-menu-button):not([disabled=true],[checked],[open],:active):hover > .toolbarbutton-badge-stack,
#main-window:is([tabsintitlebar],[customtitlebar]) :is(#PanelUI-button,#PanelUI-menu-button):not([disabled=true]):is([open],[checked],:hover:active) > .toolbarbutton-badge-stack {
  background: unset !important;
  border-color: unset !important;
  border: 0 !important;
  box-shadow: unset !important;
  outline: unset !important;				
}

/* adjust button badge */
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-button #PanelUI-menu-button .toolbarbutton-badge-stack .toolbarbutton-badge  {
  position: fixed !important;
  left: 10px !important;
  top: 7px !important;
  height: 14px !important;
}

/* button color/border */

/* orange (default) */
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-button #PanelUI-menu-button {
  background-image: linear-gradient(rgb(247,182,82), rgb(215,98,10) 95%) !important;
  border-right-color:hsla(214,89%,21%,.5) !important;
  border-left-color: hsla(214,89%,21%,.5) !important;
  border-bottom-color: hsla(214,89%,21%,.5) !important;
  box-shadow: 0 1px 0 hsla(0,0%,100%,.2) inset,
			  0 0 2px 1px hsla(0,0%,100%,.25) inset,
			  0 1px 0 0px rgba(255,255,255,.6),
			  0 -1px 0 0px rgba(255,255,255,.6),
			  1px 0 0 0px rgba(255,255,255,.6),
			  -1px 0 0 0px rgba(255,255,255,.6) !important;
}
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-button #PanelUI-menu-button:hover:not(:active):not([open]){
  background-image: radial-gradient(farthest-side at center bottom, rgba(252,240,89,.5) 10%, rgba(252,240,89,0) 70%),
					radial-gradient(farthest-side at center bottom, rgb(236,133,0), rgba(255,229,172,0)),
					linear-gradient(rgb(246,170,69), rgb(209,74,0) 95%) !important;
  border-color: rgba(83,42,6,.9) !important;
  box-shadow: 0 1px 0 hsla(0,0%,100%,.15) inset,
			  0 0 2px 1px hsla(0,0%,100%,.5) inset,
			  0 -1px 0 hsla(0,0%,100%,.2),
			  0 1px 0 0px rgba(255,255,255,.6),
			  0 -1px 0 0px rgba(255,255,255,.6),
			  1px 0 0 0px rgba(255,255,255,.6),
			  -1px 0 0 0px rgba(255,255,255,.6) !important;
}
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-button #PanelUI-menu-button:is(:hover:active,[open]){
  background-image: linear-gradient(rgb(246,170,69), rgb(209,74,0) 95%) !important;
  box-shadow: 0 2px 3px rgba(0,0,0,.4) inset,
			  0 1px 1px rgba(0,0,0,.2) inset,
			  0 1px 0 0px rgba(255,255,255,.6),
			  0 -1px 0 0px rgba(255,255,255,.6),
			  1px 0 0 0px rgba(255,255,255,.6),
			  -1px 0 0 0px rgba(255,255,255,.6) !important;
}

/*private browsing - purple */
#main-window[privatebrowsingmode=temporary]:is([tabsintitlebar],[customtitlebar]) #navigator-toolbox #PanelUI-button #PanelUI-menu-button{
  background-image: linear-gradient(rgb(153,38,211), rgb(105,19,163) 95%) !important;
}
#main-window[privatebrowsingmode=temporary]:is([tabsintitlebar],[customtitlebar]) #navigator-toolbox #PanelUI-button #PanelUI-menu-button:hover:not(:active):not([open]){
  background-image: radial-gradient(farthest-side at center bottom, rgba(240,193,255,.5) 10%, rgba(240,193,255,0) 70%),
					radial-gradient(farthest-side at center bottom, rgb(192,81,247), rgba(236,172,255,0)),
					linear-gradient(rgb(144,20,207), rgb(95,0,158) 95%) !important;
}
#main-window[privatebrowsingmode=temporary]:is([tabsintitlebar],[customtitlebar]) #navigator-toolbox #PanelUI-button #PanelUI-menu-button:is(:hover:active,[open]) {
  background-image: linear-gradient(rgb(144,20,207), rgb(95,0,158) 95%) !important;
}

/* fix for 'buttons_on_navbar_squared_buttons.css' */
#main-window:is([tabsintitlebar],[customtitlebar])[uidensity=compact] #PanelUI-menu-button .toolbarbutton-badge-stack,
#main-window:is([tabsintitlebar],[customtitlebar]):not([uidensity=compact]):not([uidensity=touch]) #PanelUI-menu-button .toolbarbutton-badge-stack,
#main-window:is([tabsintitlebar],[customtitlebar])[uidensity=touch] #PanelUI-menu-button .toolbarbutton-badge-stack {
  padding-top: 0px !important;
  padding-bottom: 0px !important;
  width: unset !important;
  height: 22px !important;
}

#main-window:is([tabsintitlebar],[customtitlebar])[uidensity=compact] #PanelUI-menu-button .toolbarbutton-icon,
#main-window:is([tabsintitlebar],[customtitlebar]):not([uidensity=compact]):not([uidensity=touch]) #PanelUI-menu-button .toolbarbutton-icon,
#main-window:is([tabsintitlebar],[customtitlebar])[uidensity=touch] #PanelUI-menu-button .toolbarbutton-icon {
  padding: 6px !important;
  width: 9px !important;
  height: 7px !important;
  outline: unset !important;
}

/* fix for toolbar + text mode */
#main-window:is([tabsintitlebar],[customtitlebar]) toolbox toolbar:not(#TabsToolbar) toolbaritem #PanelUI-menu-button,
#main-window:is([tabsintitlebar],[customtitlebar]) toolbox toolbar:not(#TabsToolbar) #PanelUI-menu-button,
#main-window:is([tabsintitlebar],[customtitlebar]) toolbox toolbar:not(#TabsToolbar) .toolbarbutton-1[type="menu-button"] #PanelUI-menu-button{
  appearance: unset !important;
}
#main-window:is([tabsintitlebar],[customtitlebar]) toolbox toolbar:not(#TabsToolbar) toolbaritem #PanelUI-menu-button .toolbarbutton-text,
#main-window:is([tabsintitlebar],[customtitlebar]) toolbox toolbar:not(#TabsToolbar) #PanelUI-menu-button:not([type="menu-button"]) .toolbarbutton-text,
#main-window:is([tabsintitlebar],[customtitlebar]) toolbox toolbar:not(#TabsToolbar) .toolbarbutton-1[type="menu-button"] #PanelUI-menu-button .toolbarbutton-text{
  display: none !important;
}
#main-window:is([tabsintitlebar],[customtitlebar]) toolbox toolbar:not(#TabsToolbar) toolbaritem #PanelUI-menu-button:not([type="menu-button"]),
#main-window:is([tabsintitlebar],[customtitlebar]) toolbox toolbar:not(#TabsToolbar) #PanelUI-menu-button:not([type="menu-button"]),
#main-window:is([tabsintitlebar],[customtitlebar]) toolbox toolbar:not(#TabsToolbar) .toolbarbutton-1[type="menu-button"] #PanelUI-menu-button{
  -moz-box-orient: unset !important;
  flex-direction: unset !important;
  min-width: unset !important;
}

#main-window:is([tabsintitlebar],[customtitlebar]) toolbox toolbar:not(#TabsToolbar) toolbaritem #PanelUI-menu-button:not(#nav-bar-overflow-button):not(#PlacesChevron) > :is(.toolbarbutton-icon,.toolbarbutton-badge-stack),
#main-window:is([tabsintitlebar],[customtitlebar]) toolbox toolbar:not(#TabsToolbar) #PanelUI-menu-button:not([type="menu-button"]):not(#nav-bar-overflow-button):not(#PlacesChevron) > :is(.toolbarbutton-icon,.toolbarbutton-badge-stack) {
  opacity: 1.0 !important;
  margin-bottom: unset !important;
}

/* support for tab title in Firefox titlebar option*/
#main-window:is([tabsintitlebar],[customtitlebar])::after {
  margin-inline-start: var(--appbutton_in_titlebar) !important;
}

/* remove this nonsense button, a menuitem is inside menu button anyways */
#PanelUI-button #whats-new-menu-button {
  display: none !important;
}

/* workaround for Firefox 71+ *******************/
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-button > *:not(#PanelUI-menu-button) {
  display: none !important;
}

#main-window:is([tabsintitlebar],[customtitlebar])[uidensity=compact] #PanelUI-menu-button .toolbarbutton-badge-stack,
#main-window:is([tabsintitlebar],[customtitlebar]):not([uidensity=compact]):not([uidensity=touch]) #PanelUI-menu-button .toolbarbutton-badge-stack,
#main-window:is([tabsintitlebar],[customtitlebar])[uidensity=touch] #PanelUI-menu-button .toolbarbutton-badge-stack,
#main-window:is([tabsintitlebar],[customtitlebar])[uidensity=compact] #PanelUI-menu-button .toolbarbutton-icon,
#main-window:is([tabsintitlebar],[customtitlebar]):not([uidensity=compact]):not([uidensity=touch]) #PanelUI-menu-button .toolbarbutton-icon,
#main-window:is([tabsintitlebar],[customtitlebar])[uidensity=touch] #PanelUI-menu-button .toolbarbutton-icon {
  width: unset !important;
  height: unset !important;
}

#TabsToolbar .titlebar-spacer[type="pre-tabs"] {
  display: none !important;
}

/* workaround for Firefox 102+ *******************/
panel[id="appMenu-popup"][type="arrow"][side="top"],
panel[id="appMenu-popup"][type="arrow"][side="bottom"] {
  margin-inline: 0 !important;
}

/* tweak button badge */
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button[badge-status="update-available"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button[badge-status="update-downloading"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button[badge-status="update-manual"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button[badge-status="update-other-instance"] > .toolbarbutton-badge-stack > .toolbarbutton-badge,
#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-menu-button[badge-status="update-restart"] > .toolbarbutton-badge-stack > .toolbarbutton-badge {
  background-image: url(chrome://browser/skin/update-badge.svg) !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  -moz-context-properties: fill !important;
  width: 14px !important;
  height: 14px !important;
}

/* aero appearance fix */
#main-window:is([tabsintitlebar],[customtitlebar]) #nav-bar #PanelUI-button toolbarbutton:not([disabled=true]):hover :is(.toolbarbutton-badge-stack,.toolbarbutton-icon),
#main-window:is([tabsintitlebar],[customtitlebar]) #nav-bar #PanelUI-button toolbarbutton:not([disabled=true]):is([open],[checked],:hover:active,:active) :is(.toolbarbutton-badge-stack,.toolbarbutton-icon) {
  background-image:	unset !important;
  outline: 0px !important;
}

/* Force appbutton to the right */
@media (-moz-platform: macos) {
	
	#main-window:is([tabsintitlebar],[customtitlebar]) #PanelUI-button {
	  right: 0 !important;
	}

	#main-window:is([tabsintitlebar],[customtitlebar]) #TabsToolbar {
	  padding-inline-end: calc(var(--appbutton_in_titlebar) + 5px) !important;
	}

	#main-window:is([tabsintitlebar],[customtitlebar]) .titlebar-buttonbox-container {
	  padding-inline-end: 20px !important;
	}

}
